package cn.monkey.family.data.crud;

import cn.monkey.family.data.QueryRequest;
import cn.monkey.family.data.Result;
import cn.monkey.family.data.context.RequestContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.util.Collection;

public interface CrudService<ID, Q extends QueryRequest, D, V> {
    Result<V> readById(RequestContext requestContext, ID id);

    Result<V> readOne(RequestContext requestContext, Q queryRequest);

    Result<Collection<V>> readAll(RequestContext requestContext, Q queryRequest, Sort sort);

    Result<Collection<V>> readAll(RequestContext requestContext, Q queryRequest);

    Result<Page<V>> readPage(RequestContext requestContext, Q queryRequest, Pageable pageable);

    Result<V> create(RequestContext requestContext, D d);

    Result<V> update(RequestContext requestContext, ID id, D d);

    Result<Void> delete(RequestContext requestContext, ID id);

    Result<Void> deleteAll(RequestContext requestContext, Collection<ID> ids);
}
